package com.bzkj.quality.enums;

/**
 * @author C1309
 */

public enum CheckPurpose {
    /** 进厂检验 */
    INCOMING_INSPECTION(1, "进厂检验"),

    /** 复验 */
    RE_INSPECTION(2, "复验"),

    /** 接近有效期 */
    NEAR_EXPIRY(3, "接近有效期"),

    /** 其他 */
    OTHER(4, "其他");

    private final int code;
    private final String description;

    CheckPurpose(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static CheckPurpose fromCode(int code) {
        for (CheckPurpose purpose : CheckPurpose.values()) {
            if (purpose.getCode() == code) {
                return purpose;
            }
        }
        throw new IllegalArgumentException("无效的请验目的代码: " + code);
    }
}
